package com.ruoyi.system.mapper;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.SysEmployee;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
//@DataSource(value = DataSourceType.SLAVE1)
public interface SysEmployeeMapper {

    /**
     * 根据组织id查处所有的人员
     * @param ORGANIZATION_CODE
     * @return
     */
    @Select("select KEY_ID, NAME, ORGANIZATION_CODE from combfream.sys_employee where ORGANIZATION_CODE = #{ ORGANIZATION_CODE }")
    @Results(
            @Result(property = "SYS_NAME", column = "NAME")
    )
    List<SysEmployee> selectSysEmployeeByOrganizationCode(@Param("ORGANIZATION_CODE") String ORGANIZATION_CODE);


    /**
     * 根据人员id查出组织名称
     * @param sysEmployeeId
     * @return
     */
    @Select("select NAME, ORGANIZATION_NAME from combfream.sys_employee where KEY_ID = #{ sysEmployeeId }")
    @Results(
            @Result(property = "SYS_NAME", column = "NAME")
    )
    SysEmployee selectNameById(@Param("sysEmployeeId")String sysEmployeeId);


    @DataSource(value = DataSourceType.SLAVE1)
    @Select("select IM_ACCOUNT from sys_employee where KEY_ID = #{ KEY_ID }")
    String getImByKeyId(@Param("KEY_ID") String keyId);

    @DataSource(DataSourceType.SLAVE1)
    @Select("select IM_ACCOUNT from sys_student where KEY_ID = #{ KEY_ID }")
    String getStuByKeyId(@Param("KEY_ID") String keyId);


}
